Project Config

October 22, 2022

Project Config

In Auto.js Pro, we sometimes need to run not only single files, but also projects. A project is a folder that contains configuration, code files, resource files (images, etc.).

You can create a new project in Auto.js Pro from the home page, and there are various project modules available (Pro 8.7 and above).

project.json

The project.json file is used to configure project related parameters, such as master file, startup image, package name and other information.

Parameter nameMeaningTypeDefault value
androidResourcesAndroid resources, see androidResourcesopen in new windowObject{
"resDir": "res",
"manifest ": "AndroidManifest.xml"
}
buildAuto-generated build information, no need to modify, see buildopen in new windowObject
assetsReserved field, no effect for nowArray<String>[]
encryptLevelencryptionLevel 0-no encryption, 1-local encryption, 2-online encryption (only supported in 8.7+)number0
icondesktop iconstring"icons/icon.png"
ignoreIgnore files when syncing projects from VSCodeArray["build"]
launchConfigLaunch configuration, see launchConfigopen in new windowObject
mainThe entry filestring"main.js"
nameapp namestring""
optimizationOptimization configuration, see optimizationopen in new windowObject
packageNamePackage name, must conform to Android package name specification, and the package name must be unique when uploading to the storestring""
permissionConfigPermission Config, see permissionConfigopen in new windowObject{
"manifestPermissions": [],
"requestListOnStartup": []
}
publishThe publish/upload store configuration, see publishopen in new windowObject
scriptsThe configuration of scripts that are automatically triggered to run when building, etc., see scriptsObject
versionCodeversion numbernumber1
versionNamename of the version to show to the userstring"1.0.0"

Example of full configuration.

{
  "androidResources": {
    "resDir": "res",
    "manifest": "AndroidManifest.xml"
  },
  "assets": [],
  "build": {
    "build_id": "6F47F367-1",
    "build_number": 1,
    "build_time": 1615553004812,
    "release": true
  },
  "encryptLevel": 0,
  "useFeatures": [],
  "icon": "res/icon.png",
  "ignore": ["build"],
  "launchConfig": {
    "displaySplash": true,
    "hideLogs": false,
    "splashIcon": "res/splashIcon.png",
    "splashLayoutXml": "splash.xml",
    "splashText": "Powered by Auto.js Pro",
    "stableMode": false
  },
  "main": "main.js",
  "name": "Shape3.0",
  "optimization": {
    "removeOpenCv": true,
    "unusedResources": true
  },
  "packageName": "com.suzy.rippledrawable",
  "permissionConfig": {
    "manifestPermissions": ["android.permission.WRITE_EXTERNAL_STORAGE"],
    "requestListOnStartup": ["android.permission.WRITE_EXTERNAL_STORAGE"]
  },
  "publish": {
    "category": "Other",
    "details": "control stroke, gradient, ripple, text gradient",
    "maxAutoJsVersion": -1,
    "minAutoJsVersion": -1,
    "maxProVersion": 8059999,
    "minProVersion": 8050000,
    "minSdkVersion": 2,
    "permissions": [],
    "summary": "control stroke, gradient, water ripple, text gradient",
    "tags": []
  },
  "scripts": {},
  "versionCode": 1,
  "versionName": "1.0.0"
}

Minimum configuration example.

{
    "name": "New Project",
    "main": "main.js",
    "ignore": [
        "build"
    ],
    "packageName": "com.example",
    "versionName": "1.0.0",
    "versionCode": 1
}

androidResources

Parameters used to configure Android native interface, see Example->Complex Interface->Android Native Interface.

parameter namemeaningtypedefault
resDirAndroid resource folderstring"res"
manifestThe path to the AndroidManifest.xml filestring"AndroidManifest.xml"

build

The automatically generated build information, including build time, build number, etc., please do not modify.

The package software will determine whether to unpack the files of the installation package to the data path according to the information here. (The confidence here will be updated after each package, so the project files in the local data can be updated automatically after installation)

Parameter NameMeaningTypeDefault
build_idAuto-generated build idstring""
build_numberBuild number, incremented by 1 per buildnumber1
build_timelast build timenumbercurrent 13-bit timestamp
releaseWhether or not the project is a packaged project, this is an auto-generated field that does not need to be modifiedbooleanfalse

launchConfig

The launch configuration of the packaged project.

parameter namemeaningtypedefault
displaySplashWhether or not to display the launch graph after packaging (even if set to false, the launch graph will still be displayed the first time after packaging)booleantrue
hideLogsHide the logs after packagingbooleanfalse
splashIconThe splash interface icon after packagingstring"icons/splashIcon.png"
splashLayoutXmlSplashLayoutXmlThe startup image xml, used to customize the startup image after packaging, see Example->Projects and Packaging->Customizing the startup image (version 8.5 or above)string
splashTextPacked startup interface textstring"Powered by Auto.js Pro"
stableModeWhether to run in stable mode after packagingbooleanfalse

permissionConfig

Added in Pro 8.8.1

Custom permission configuration, including the permissions list of the built apk, and the permission list to request when starting up.

You can also use the Auto.js Pro permission settings UI to modify permission config.

parametermeaningtypedefault
manifestPermissionsThe declared permission list. For compatibility with the old version, if the field is null, the default is 122 built-in permissions.Array<string>null
requestListOnStartupthe permission list to request when starting up,permission must be included in manifestPermissions, otherwise it cannot be requestedArray<string>["android.permission.WRITE_EXTERNAL_STORAGE"]

For all permission list, see Manifest.permissionopen in new window

publish

The configuration for uploading the store publish project.

parameter namemeaningtypedefault
maxAutoJsVersionThe maximum autojs version number supportednumber0
maxProVersionmaximum supported autojspro versionnumber0
minAutoJsVersionminimum autojs version supportednumber0
minProVersionmaximum supported autojspro versionnumber0
minSdkVersionMinimum supported Android versionsnumber0
categoryThe category of the project to be used as a category when publishing to the storestring"Other"
detailsProject details, used as project details when publishing to the storestring""
permissionsA list of permissions, such as "root", which is not available at the momentArray<Stirng>[]
summaryScript feature summarystring""
tagsScript tags, no effect for now since the store doesn't have tag filtering yetArray<String>[]

optimization

Optimize the configuration. Currently used to reduce size when packaging.

parameter namemeaningtypedefault
removeOpenCvdo not need the images module with opencvbooleanfalse
unusedResourcesdon't need built-in iconsbooleanfalse

ignore configuration

Added in Pro 8.7.6

The ignore configuration file is similar to .gitignore, which is used to configure Auto.js Pro to process the ignored files such as packaging and encryption.

The rules of ignore file are the same as .gitignore, for example:

# / Indicates the directory where the current file is located

# Ignore all directories and files under public
/public/
#Don’t ignore/public/assets, which means a special case, assets files are not ignored
!/public/assets

# Ignore specific files

index.js

# Ignore all js files
*.js

# Ignore a.js b.js
[ab].js

# Matching rules are the same as linux file matching
# Start with a slash "/" to indicate a directory
# Use an asterisk "*" to wildcard multiple characters
# Use a question mark "?" to wildcard a single character
# Use square brackets "[]" to contain a single character match list
# Use an exclamation mark "!" to indicate not to ignore (track) the matched files or directories

.autojs.source.ignore

File path: .autojs.source.ignore file in the project folder.

The files matched by the rules of the file configuration will not be regarded as Auto.js Pro JavaScript source files and will not participate in the encryption process.

For example, some js files are used for loading on the Web, and you do not want to encrypt them when packaging, you can configure this file to ignore.

.autojs.build.ignore

File path: .autojs.build.ignore file under the project folder.

The file matched by the rules of the file configuration will not participate in the Auto.js Pro packaging apk process, and the final generated apk will not contain the specified file.

For example, sometimes node_modules is only used during development, and it has been packaged as a single file by tools such as webpack when it is finally packaged. You can configure to ignore the node_modules folder.

.autojs.sync.ignore

File path: .autojs.sync.ignore file under the project folder.

The files matched by the rules configured in this file will be ignored when the VSCode plug-in runs, synchronizes, and saves files on the computer. Only available for Pro 9.3+.

scripts

The scripts field is used to configure the shell commands that are automatically executed at times such as building. E.g:

{
   //...
   "scripts": {
     "build-apk-pre-prepare": "sh build.sh"
   },
   //...
}

The above configuration will automatically run the build.sh script before packaging the apk, so that custom file replacement, obfuscation, etc. can be performed before packaging. In these shell commands, you can use node build.js to execute js files (pure Node.js environment); currently, it does not support executing js scripts in Auto.js environment.

The following timings are currently supported:

Triggered when building apk

Auto.js Pro builds the apk in several stages:

  • Preparation stage: copy project files, apk files, process source files, etc.
  • Construction phase: execute aapt compilation, add built-in icon packs, modify and write Manifest files, process plug-ins, etc.
  • Optimization phase: remove useless resources, modules, obfuscated components, etc.
  • Packaging phase: signing, compressing, cleaning up workspace, etc.

The sh scripts to be executed can be customized at different stages. In these scripts, information can be obtained through the following environment variables:

  • BUILD_APK_WORKSPACE: The temporary workspace for the build, that is, the temporary project for decompressing the apk
  • BUILD_APK_WORKSPACE_PROJECT: The project folder under the workspace, the project will be copied here
  • BUILD_APK_OUTPUT: target output path of apk

The current project path can be obtained by commands such as pwd.

The names corresponding to each stage are:

  • build-apk-pre-prepare: Triggered before the prepare phase

  • build-apk-post-prepare: Triggered after the exact phase

  • build-apk-pre-build: Triggered before the build phase

  • build-apk-post-build: Triggered after the build phase

  • build-apk-pre-optimize: Triggered before the optimization phase

  • build-apk-post-optimize: Triggered after the optimize phase

  • build-apk-pre-package: Triggered before the packaging phase

  • build-apk-post-package: Triggered after the packaging phase

Last update:
Contributors: hyb1996